Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

197
Visualizações
Decoding "unknown" strings to UTF-8 with Javascript

I have a text source that sends me encoded Strings, for the most part, the JavaScript function decodeURIComponent(escape(str)) works, But I've logged some weird "unknown" characters that broke the decodeURIComponent function, for now I have a workaround with replaceAll:

function fixWeirdCharacters(str){
  return str.replaceAll('à', "a").replaceAll('Ó','O').replaceAll('ÇÃO','CAO').replaceAll('Ú','U').replaceAll('ÃÂ','A').replaceAll('ó','o').replaceAll('ÇÕ','CO').replaceAll('É','E');
}

the following characters gave me error so far (encoded character = expected string):

Ã&nbsp = à
Ó = Ó
ÇÃO = ÇÂO
Ú = Ú
à= ó = ó
ÇÕ = ÇÕ
É = É

the assumption of the correct character was made by looking at the entire word, the main purpose is to decode it to UTF-8 and use it on regular HTML 5 page

Any idea of what might be creating those characters or how to decode them properly using JavaScript only?

Obs: I tried to decode them on PHP using urldecode(), and the result is an "?" box character..

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda